<?php
function generateMenu($menuitems = null, $view){
	
	$auth = Zend_Auth::getInstance();
	$acl = Acl::getInstance();

	$role = 'visitor';
	if ($auth->hasIdentity()) {
		$user = $auth->getIdentity()->getUser();
		$role = $user['role'];
	}

	$navigationMenu = new Zend_Navigation();
	foreach($menuitems as $item){
		if ($acl->has($item->getModule()) && $acl->isAllowed($role, $item->getModule(),$item->getController()) && $item->get('label')){
			$navigationMenu->addPage($item);
		}
	}

	$menu = array();
	foreach($navigationMenu->getPages() as $page){
		$active = "";
		if($page->isActive()){
			$active = 'active';
		}
		$menu[] = '<a class="'.$active.'" href="'.$page->getHref().'">'.$page->get('label').'</a>';
	}
	
	return join(" | ",$menu);
}
?>